import React, { Component } from "react";
import { Select } from "antd";
import { getChannels } from "api/channels";
const { Option } = Select;
export default class Channels extends Component {
  state = {
    channels: [],
  };
  getChannelLists = async () => {
    let { channels } = await getChannels();

    this.setState({ channels: channels });
  };
  componentDidMount() {
    this.getChannelLists();
  }
  render() {
    const { channels } = this.state;
    return (
      <div>
        <Select
          style={{ width: 200 }}
          size="mini"
          placeholder="请选择频道"
          value={this.props.value}
          onChange={this.props.onChange}
        >
          {channels.map(item => (
            <Option key={item.id} value={item.id}>
              {item.name}
            </Option>
          ))}
        </Select>
      </div>
    );
  }
}
